// pages/search/search.js
const http = require("../../models/http")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value:""
  },

  handleSubmit(event){
    console.log(event.detail.value.content);
    http({
      url:`http://192.168.4.18:3000/search?keywords=${event.detail.value.content}&type=10`,
      success:res=>{
        this.setData({
          value:res.data.result.albums
        })
        console.log(this.data.value);
      }
    })
  },
  // 点击变换状态
  onClick(event){
    this.data.value.forEach(res=>{
      if(res.id==event.currentTarget.dataset.id){
        res.state = !res.state
      }else{
        res.state = false
      }
    })
    this.setData({
      value:this.data.value
    })
    // console.log(this.data.value);
  }
})